package com.library.mapper;

import com.library.pojo.dto.user.UserDTO;
import com.library.pojo.dto.user.UserPageQueryDTO;
import com.library.pojo.entity.LibraryUsers;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * 用户信息表Mapper接口
 */
public interface UserMapper {

    /**
     * 根据用户ID查询用户信息
     * @param userId
     * @return com.library.pojo.entity.LibraryUsers
     * @author TanyDe
     * @create 2025/11/14
     **/
    LibraryUsers selectById(Integer userId);

    /**
     * 根据用户名查询
     * @return
     * @author TanyDe
     * @create 2025/11/14
     **/
    LibraryUsers selectByUserName(String username);

    /**
     * 插入新用户
     *
     * @param user
     * @return void
     * @author TanyDe
     * @create 2025/11/14
     **/
    int insert(LibraryUsers user);

    /**
     * 更新用户信息
     * @param user
     * @return void
     * @author TanyDe
     * @create 2025/11/14
     **/
    int update(LibraryUsers user);

    /**
     * 根据用户ID删除用户
     * @param userId
     * @return void
     * @author TanyDe
     * @create 2025/11/14
     **/
    int deleteById(Integer userId);

    /**
     * 分页查询用户信息（必填：pageNum/pageSize；可选：userId/username关键词）
     * @return
     * @author TanyDe
     * @create 2025/11/14
     **/
    List<LibraryUsers> pageQuery(@Param("userId") Integer userId,
                            @Param("username") String username,
                            @Param("pageSize") int pageSize,
                            @Param("offset") int offset);

    /**
     * 统计用户数量
     * @return
     * @author TanyDe
     * @create 2025/11/14
     **/
    int count();
}
